﻿using UnityEngine;

namespace ProjectSurvivor
{
    public class DamageSystem
    {
        public static void CalculateDamage(float baseDamage, IEnemy enemy, int MaxNormalDamage = 2,
            float criticalDamageTime = 5)
        {
            baseDamage *= Global.DamageRate.Value;
            if (Random.Range(0, 1.0f) < Global.CritcalRate.Value)
            {
                enemy.Hurt(baseDamage*Random.Range(2f,criticalDamageTime),false,true);
            }
            else
            {
                enemy.Hurt(baseDamage+Random.Range(-1,MaxNormalDamage));
            }
            
        }
    }
}